package com.myproject.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.myproject.model.SysUser;

@Configuration
public class CustomerUserService implements UserDetailsService {
	
	@Autowired
	private SysUserService sysUserService;
	
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		SysUser user = sysUserService.findSysUserByUsername(username);
		if(user == null){
			throw new UsernameNotFoundException("user not found!");
		}
		//在下面可进行一些授予权限的操作
		
		return user;
	}

}
